#if !defined(AFX_FLYVIEW_H__888ECBFC_1532_4C57_A10A_D1926DB3A063__INCLUDED_)
#define AFX_FLYVIEW_H__888ECBFC_1532_4C57_A10A_D1926DB3A063__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FlyView.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CFlyView form view

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif


#include "GStationDoc.h"

#include "Scope.h"
#include "ShowTrack.h"

// For rendering 3d aircraft model added by hujingfei914@msn.com
#include "3DAircraftModel\OpenGLControl.h"

#include "./oslayer/cir2ned.h"


typedef struct ViewConfig
{
	int psi_S;
	int psi_T;
	int psi_target_S;
	int psi_target_T;
	int psi_err_S;
	int psi_err_T;
	int r_S;
	int r_T;
	int psi_actuator_S;
	int psi_actuator_T;

	int phi_S;
	int phi_T;
	int phi_target_S;
	int phi_target_T;
	int phi_err_S;
	int phi_err_T;
	int p_S;
	int p_T;
	int phi_actuator_S;
	int phi_actuator_T;

	int theta_S;
	int theta_T;
	int theta_target_S;
	int theta_target_T;
	int theta_err_S;
	int theta_err_T;
	int q_S;
	int q_T;
	int theta_actuator_S;
	int theta_actuator_T;

	int D_pos_S;
	int D_pos_T;
	int D_pos_target_S;
	int D_pos_target_T;
	int D_pos_err_S;
	int D_pos_err_T;
	int D_Acc_S;
	int D_Acc_T;
	int col_actuator_S;
	int col_actuator_T;
		
	int N_pos_S;
	int N_pos_T;
	int N_pos_target_S;
	int N_pos_target_T;
	int N_pos_err_S;
	int N_pos_err_T;
	int N_Acc_S;
	int N_Acc_T;

	int E_pos_S;
	int E_pos_T;
	int E_pos_target_S;
	int E_pos_target_T;
	int E_pos_err_S;
	int E_pos_err_T;
	int E_Acc_S;
	int E_Acc_T;
}*pViewConfig;

class CFlyView : public CFormView
{
public:
	CFlyView();           // protected constructor used by dynamic creation
protected:
	DECLARE_DYNCREATE(CFlyView)

// Form Data
public:
	//{{AFX_DATA(CFlyView)
	enum { IDD = IDD_FORMVIEW_Fly };
	CButton	m_TestDataBack;
	CEdit	m_testin;
	CButton	m_FlyStop;
	CProgressCtrl	m_SaveFliedData_Process;
	CButton	m_HotStart;
	CButton	m_FlyReady;
	CButton	m_TakeOff;
	CButton	m_Land;
	CButton	m_LoadModel;
	CButton	m_LoadCtlPara;
	CButton	m_Load_Actuator;
	CShowTrack	m_ShowTrack;
	CButton	m_StopData;
	CButton	m_SaveData;
	CString	m_s1;
	CString	m_s3;
	CString	m_ShowFlytime;
	UINT	m_NextPathPoint;
	int		m_testout;
	//}}AFX_DATA

// Attributes
public:


	
	double show_value[5][5];
	ViewConfig vconfig;
	CGStationDoc * doc;
	bool is_model_loaded;
	bool is_ctlpara_loaded;
	long pathpointsentstate;
	bool is_actuator_loaded;
	bool is_run;

	CString xlsname;
	bool xlstag;
	long serial_t;

	CScope m_wndScope1;
	CScope m_wndScope2;
	CScope m_wndScope3;
	CScope m_wndScope4;

	bool starttrack;

	int frame_serial;
	CString file_path;

	CFile xls_Save_file;

	Cir2NED ir_2_ned;

	// For rendering 3d aircraft model
private:
	COpenGLControl m_oglWindow;
// Operations
public:
	bool OnFlyReadyBtn;
	bool OnBtnHotStart;
	double time_interval;

	bool StartSaveXLSFile;
	bool StartSaveFSDFile;

	bool Btn_Flyready_FirstTime;


	int FlyStartTime_Hour;
	int FlyStartTime_Minute;
	int FlyStartTime_Second;
	
	void OnSend(int serial);
	void SaveAndShow(FlyState * fg);
	bool OnSendPaths(long serial);
	CGStationDoc * GetDocument();
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CFlyView)
	public:
	virtual void OnInitialUpdate();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CFlyView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CFlyView)
	afx_msg void OnLoadModel();
	afx_msg void OnLoadCtlPara();
	afx_msg void OnStartExp();
	afx_msg void OnLoadActuator();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnSavedata();
	afx_msg void OnStopdata();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnButtonTakeoff();
	afx_msg void OnButtonLand();
	afx_msg void OnHotStart();
	afx_msg void OnStartsenddata();
	afx_msg void OnPitchIncrease();
	afx_msg void OnPitchDecrease();
	afx_msg void OnRollIncrease();
	afx_msg void OnRollDecrease();
	afx_msg void OnBtnNextpath();
	afx_msg void OnStopExp();
	afx_msg void OnButtonStall();
	afx_msg void OnButtonGo();
	afx_msg void OnButtonBack();
	afx_msg void OnBUTTONTestDataBack();
	afx_msg void OnButton2();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FLYVIEW_H__888ECBFC_1532_4C57_A10A_D1926DB3A063__INCLUDED_)
